package com.zc.im.rabbitmq;

import com.zc.im.util.properties.RabbitmqProperties;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
@Component
public class Runner implements CommandLineRunner{
    @Autowired
    private RabbitmqProperties rabbitmqProperties;
    @Autowired
    private  RabbitTemplate rabbitTemplate;

    @Override
    public void run(String... args) throws Exception {
        if(args == null || args.length ==0){
            return;
        }

        StringBuffer dataBuffer = new StringBuffer();
        for(String str :args){
            dataBuffer.append(str);
        }
        rabbitTemplate.convertAndSend(rabbitmqProperties.getRabbitSendQueueName(), dataBuffer.toString());
    }
}